home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_weap_whip.cog < prev    next >
Text File  |  1999-11-15  |  7KB  |  361 lines

  1. # Jones 3D Cog Script
  2. #
  3. # weap_Whip.cog
  4. #
  5. # This COG controls Indy's whip.
  6. #
  7. # [RandyT]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. #
  11. # ===================================================================
  12.  
  13. symbols
  14.  
  15. message        startup
  16. message        fire
  17. message        aim
  18. message        activated
  19. message        deactivated
  20. message        selected
  21. message        deselected
  22. message        callback
  23. message        user0
  24.  
  25. model        handleHand=weap_whip.3do    local    # Autoloaded
  26.  
  27. sound        snap=gen_whip_fire.wav        local    # Autoloaded
  28. sound        pull=gen_whip_pull.wav        local    # Autoloaded
  29. sound        put=gen_whip_put.wav        local    # Autoloaded
  30. sound        unroll=gen_whip_unravel.wav    local    # Autoloaded
  31. sound        roll=gen_whip_ravel.wav        local    # Autoloaded
  32. sound        zap                            local
  33.  
  34. template    leather=+whip                local    # Autoloaded
  35. template    electric=+whip_electric        local    # Aetherium only
  36. template    whip=+whip_actor            local    # Autoloaded
  37.  
  38. thing        whipThing=-1                local
  39. thing        indy                        local
  40.  
  41. flex        fireWait=1.25                local    # Fire is 37 frames at 30fps
  42.  
  43. int            handMesh                    local
  44. int            whipMesh                    local
  45. int            joint                        local
  46. int            weaponNum=2                    local
  47. int            swapRef=-1                    local
  48. int            callNum                        local
  49. int            sender                        local
  50.  
  51. int            bActivated=0                local
  52.  
  53. end
  54.  
  55. # ===================================================================
  56.  
  57. code
  58.  
  59. startup:
  60.  
  61.     indy = GetLocalPlayerThing();
  62.  
  63.     handMesh = GetMeshByName(indy, "inrhand");
  64.     whipMesh = GetMeshByName(indy, "inwhip");
  65.  
  66.     # Indy is wearing the whip by default
  67.     LoadHolsterModel(weaponNum, "weap_whip_hip.3do");
  68.     SetHolsterModel(indy, weaponNum, whipMesh);
  69.  
  70.     # Electro whip sound -- Atherium only
  71.     if ((IsLevelName("15_aet.cnd")) || (IsLevelName("15_aet.ndy")))
  72.     {
  73.         zap = LoadSound("aet_whip_crack.wav");
  74.     }
  75.  
  76.     return;
  77.  
  78. # -------------------------------------------------------------------
  79.  
  80. fire:
  81.  
  82.     # If the message is from the weapons system, play the animation
  83.     if (GetParam(0) != -1)
  84.     {
  85.         SetFireWait(indy, fireWait);
  86.         CaptureThing(indy);
  87.  
  88. #        PlayMode(indy, 65, 0);
  89. #        PlayMode(whipThing, 65, 0);
  90.         while (PlayMode(indy, 65, 0) == -99)
  91.         {
  92.             Sleep(0.01);
  93.         }
  94.         while (PlayMode(whipThing, 65, 0) == -99)
  95.         {
  96.             Sleep(0.01);
  97.         }
  98.  
  99.         return;
  100.     }
  101.  
  102.     # Actual firing takes place when we get the callback...
  103.     if (BitTest(GetActorFlags(indy), 0x40000000)) # Electric whip
  104.     {
  105.         FireProjectile(indy, electric, zap, -1, GetThingPos(indy), '0 0 0', 1.0, 0x0, 0.0, 0.0);
  106.  
  107.         ChangeInv(indy, weaponNum, -1.0); # Decrease bin by 1...
  108.  
  109.         if (GetInv(indy, weaponNum) < 1) # Turn it off if it's outta juice...
  110.         {
  111.             Sleep(0.5);
  112.             SetWhipElectric(0);
  113.  
  114.             SetInv(indy, weaponNum, 1.0); # Reset the bin to 1...
  115.             SetInvAvailable(indy, weaponNum, 1);
  116.         }
  117.     }
  118.     else
  119.         FireProjectile(indy, leather, snap, -1, GetThingPos(indy), '0 0 0', 1.0, 0x0, 0.0, 0.0);
  120.  
  121.     return;
  122.  
  123. # -------------------------------------------------------------------
  124.  
  125. aim:
  126.  
  127.     if (GetParam(0))
  128.     {
  129.         if (!IsAiming(indy) && !bActivated)
  130.         {
  131.             PlayMode(indy, 63, 0);
  132. #            while ((PlayMode(indy, 63, 0) == -99) && (!bActivated))
  133. #            {
  134. #                Sleep(0.01);
  135. #            }
  136.         }
  137.     }
  138.     else if (IsModePlaying(indy, 63) && !bActivated)
  139.     {
  140.         SetAimWait(indy, 0.2);
  141.         StopMode(indy, 63, 0.2);
  142.     }
  143.  
  144.     return;    
  145.  
  146. # -------------------------------------------------------------------
  147.  
  148. activated:
  149.  
  150.     # See if this is a whip swing or climb
  151.     if (GetSenderRef() == -99)
  152.     {
  153.         # if (pThing->moveStatus == SITHPLAYERMOVE_WHIPSWINGING) 
  154.         if (GetMoveStatus(indy) == 10)
  155.         {
  156.             StopMode(indy, 63, 0.0);
  157.             EnableInterface(0);
  158.         }
  159.  
  160.         return;
  161.     }
  162.  
  163.     bActivated = 1;
  164.     SetAimWait(indy, 1.5);
  165.  
  166.     # Disable indy controls
  167.     SetActorFlags(indy, 0x40000);
  168.     EnableInterface(0);
  169.  
  170.     if (!IsAiming(indy))
  171.     {   
  172.         PlayMode(indy, 63, 0);
  173. #        while (PlayMode(indy, 63, 0) == -99)
  174. #        {
  175. #            Sleep(0.01);
  176. #        }
  177.     }
  178.  
  179.     Sleep(0.2); # 6 Frames
  180.     PlayMode(indy, 67, 0);
  181.  
  182.     if (whipThing == -1)
  183.     {
  184.         whipThing = AttachThingToThingMesh(indy, whip, handMesh);
  185.         SetThingFlags(whipThing, 0x10);
  186.         swapRef = SetThingMesh(indy, handMesh, handleHand, 0);
  187.     }
  188.  
  189.     PlayMode(whipThing, 67, 0);
  190.     Sleep(0.01);
  191.     ClearThingFlags(whipThing, 0x10);
  192.     ActivateWeapon(indy, 1.1);
  193.  
  194.     PlaySoundThing(unroll, indy, 1, -1, -1, 0x880);
  195.  
  196.     return;
  197.  
  198. # -------------------------------------------------------------------
  199.  
  200. deactivated:
  201.  
  202.     # See if this is a whip swing or climb
  203.     if (GetSenderRef() == -99)
  204.     {
  205.         # If we're not in a cutscene, restore interface
  206.         if(!GetCutsceneMode())
  207.         {
  208.             EnableInterface(1);
  209.         }
  210.         return;
  211.     }
  212.  
  213.     bActivated = 0;
  214.  
  215.     # Deactivate the weapon
  216.     DeactivateWeapon(indy);
  217.  
  218.     # Stop unravels
  219.     StopMode(indy, 67, 0);
  220.     if (whipThing != -1)
  221.         StopMode(whipThing, 67, 0);
  222.  
  223.     if (!IsAiming(indy))
  224.     {
  225.         SetAimWait(indy, 1.33); # 6 aim + 34 ravel = 40 frames
  226.         StopMode(indy, 63, 0.2);
  227.     }
  228.     else
  229.     {
  230.         SetAimWait(indy, 1.13);
  231.     }
  232.  
  233.     # Start wind-ups
  234.     CaptureThing(indy);
  235.     PlayMode(indy, 68, 0);
  236.  
  237.     if (whipThing != -1)
  238.     {
  239.         CaptureThing(whipThing);
  240.         PlayMode(whipThing, 68, 0);
  241.     }
  242.  
  243.     PlaySoundThing(roll, indy, 1, -1, -1, 0x880);
  244.  
  245.     return;
  246.  
  247. # -------------------------------------------------------------------
  248.  
  249. selected:
  250.  
  251.     SetMountWait(indy, 1.0);
  252.  
  253.     SetArmedMode(indy, 1);
  254.     SetCurWeapon(indy, weaponNum);
  255.     SetThingFireOffset(indy, '0.0 0.0 0.0'); 
  256.  
  257.     CaptureThing(indy);
  258.     PlayMode(indy, 62, 0);
  259.  
  260.     return;
  261.  
  262. # -------------------------------------------------------------------
  263.  
  264. deselected:
  265.  
  266.     # Restore camera in case we're on a whip launch surface...
  267.     RestoreExtCam();
  268.  
  269.     if (IsAiming(indy))
  270.     {
  271.         SetAimWait(indy, 0.2);
  272.         StopMode(indy, 63, 0.2);
  273.     }
  274.  
  275.     SetMountWait(indy, 1.5);
  276.  
  277.     StopMode(indy, 62, 0);
  278.  
  279.     CaptureThing(indy);
  280.     PlayMode(indy, 64, 0);
  281.  
  282.     SetArmedMode(indy, 0);
  283.  
  284.     return;
  285.  
  286. # -------------------------------------------------------------------
  287.  
  288. callback:
  289.  
  290.     sender = GetSenderRef();
  291.     callNum = GetParam(1);
  292.  
  293.     if (sender == indy)
  294.     {
  295.         ReleaseThing(indy);
  296.  
  297.         if (callNum == 28)
  298.         {
  299.             PlaySoundThing(pull, indy, 1, -1, -1, 0x880);
  300.             ResetHolsterModel(indy, 1);
  301.             SetWeaponModel(indy, weaponNum);
  302.         }
  303.         else if (callNum == 29)
  304.         {
  305.             PlaySoundThing(put, indy, 1, -1, -1, 0x880);
  306.             SetHolsterModel(indy, weaponNum, whipMesh);
  307.             ResetWeaponModel(indy);
  308.         }
  309.         else if (callNum == 30)
  310.         {
  311.             if(!GetCutsceneMode())
  312.             {
  313.                 EnableInterface(1);
  314.             }
  315.             ClearActorFlags(indy, 0x40000);
  316.         }
  317.     }
  318.     else if (sender == whipThing)
  319.     {
  320.         if (callNum == 28)
  321.         {
  322.             for (joint = 12; joint > 4; joint = joint - 1)
  323.             {
  324.                 AmputateJoint(whipThing, joint);
  325.             }
  326.         }
  327.         else if (callNum == 29)
  328.         {
  329.             AmputateJoint(whipThing, 4);
  330.         }
  331.         else if (callNum == 30)
  332.         {
  333.             AmputateJoint(whipThing, 3);
  334.         }
  335.         else if (callNum == 31)
  336.         {
  337.             ReleaseThing(whipThing);
  338.             AmputateJoint(whipThing, 2);
  339.  
  340.             if (whipThing != -1)
  341.             {
  342.                 DetachThingMesh(whipThing);
  343.                 SetWeaponModel(indy, weaponNum); 
  344.             }
  345.             whipThing = -1;
  346.         }
  347.     }
  348.  
  349.     return;
  350.  
  351. # -------------------------------------------------------------------
  352.  
  353. user0:
  354.  
  355. # This message indicates that a whipswing has started
  356.  
  357.     whipThing = GetSenderRef();
  358.     return;
  359.  
  360. end
  361.